package com.linln.agent.member;

import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.EntityBeanUtil;
import com.linln.common.utils.ResultVoUtil;
import com.linln.common.utils.StatusUtil;
import com.linln.common.vo.ResultVo;
import com.linln.modules.member.domain.Feedback;
import com.linln.modules.member.service.FeedbackService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author hct
 * @date 2021/03/09
 */
@Controller
@RequestMapping("/agent/feedback")
public class AgentFeedbackController {

    @Autowired
    private FeedbackService feedbackService;

    /**
     * 列表页面
     */
    @GetMapping("/index")
    public String index(Model model, Feedback feedback) {

        // 创建匹配器，进行动态查询匹配
        ExampleMatcher matcher = ExampleMatcher.matching();

        // 获取数据列表
        Example<Feedback> example = Example.of(feedback, matcher);
        Page<Feedback> list = feedbackService.getPageList(example);

        // 封装数据
        model.addAttribute("list", list.getContent());
        model.addAttribute("page", list);
        return "/agent/feedback/index";
    }


    /**
     * 跳转到详细页面
     */
    @GetMapping("/detail/{id}")
     public String toDetail(@PathVariable("id") Feedback feedback, Model model) {
        model.addAttribute("feedback",feedback);
        return "/agent/feedback/detail";
    }

}